package com.turtle3d.visualizator;

import java.awt.Color;

import javax.media.j3d.BranchGroup;
import javax.media.j3d.Shape3D;
import javax.media.j3d.Transform3D;
import javax.media.j3d.TransformGroup;
import javax.vecmath.Color3f;
import javax.vecmath.Matrix4f;

import com.turtle3d.formallanguage.symbol.SymbolFactory;

public abstract class Visualizator
{

	public abstract BranchGroup visualize(VisualData visualData);
	
	public void setRequiredParameters(){
		
	}
	
	protected void setRequiredParamter(String name, float value){
		if(!SymbolFactory.getSymbolFactory().defaultParameterExists(name))
			SymbolFactory.getSymbolFactory().setParameter(name, value);
	}
	
	protected TransformGroup createTransformGroup(Matrix4f transform, Shape3D object){
		TransformGroup tg = new TransformGroup();
		Transform3D t = new Transform3D();
		t.set(transform);
		tg.setTransform(t);
		tg.addChild(object);
		
		return tg;
	}
	
	protected Color3f getRainbowColor(float normalizedIndex){		
		return new Color3f(Color.getHSBColor(1.0f * normalizedIndex, .8f, .8f));
	}

}
